package com.syswin.lhztest.demoSwagger;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;

import java.util.concurrent.CountDownLatch;

/**
 * @author:lhz
 * @date:2018/12/8 20:33
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class MultiThreadTest1 {

	private static final int THREAD_NUM =  1000;
	private CountDownLatch countDownLatch = new CountDownLatch(THREAD_NUM);
	@Test
	@Transactional
	public void initTest(){
		Thread[] threads = new Thread[THREAD_NUM];
		for (int i = 0; i <THREAD_NUM ; i++) {
			Thread thread =  new Thread(()->{
				try {
					countDownLatch.await();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});
			threads[i] = thread;
			thread.start();
			countDownLatch.countDown();
		}

	}
}
